package org.example.casemodule.controller;

import com.mybatisflex.core.paginate.Page;
import org.example.casemodule.dto.CaseQueryDTO;
import org.example.casemodule.dto.UpdateStatusDTO;
import org.example.casemodule.vo.CaseVO;
import org.example.common.config.Result;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.example.casemodule.service.ILegalCaseService;
import org.example.casemodule.entity.LegalCaseEntity;

import java.io.Serializable;
import java.util.List;

/**
 * 案件表 控制层。
 *
 * @author mybatis-flex-helper automatic generation
 * @since 1.0
 */
@RestController
@RequestMapping("/api/case")
@Validated
public class LegalCaseController {

    @Autowired
    private ILegalCaseService legalCaseService;
    /**
     * 案件列表查询	核心功能	/api/case/list	管理员/律师查看案件列表（支持多条件筛选）
     */
    @GetMapping("/list")
    public Result list(@ModelAttribute @Validated CaseQueryDTO caseQueryDTO){
        Page<CaseVO> list = legalCaseService.pageList(caseQueryDTO);
        return Result.ok(list);
    }
//    /api/case/status 案件状态变更接口
    @PutMapping("/status")
    public Result updateStatus(@RequestBody UpdateStatusDTO updateStatusDTO){
        return legalCaseService.updateCaseStatus(updateStatusDTO);

    }
    // GET /api/case/detail/CASE20240512001
    @GetMapping("/detail/{caseId}")
    public Result detail(@PathVariable("caseId") String caseId){
        CaseVO detail = legalCaseService.getCaseDetail(caseId);
        return Result.ok(detail);
    }




}